
local songwei = fk.CreateSkill{
  name = "ls__songwei",
  tags = { Skill.Lord },
}

Fk:loadTranslationTable{
  ["ls__songwei"] = "颂威",
  [":ls__songwei"] = "主公技，其他魏势力角色使用“登极”记录的牌后，可令你重置“登极”或“威赦”。",
  ["#ls__songwei-reset"] = "颂威：你可令%src重置一个技能",
  
  ["$ls__songwei1"] = "魏王世子,定登大统！",
  ["$ls__songwei2"] = "千古霸业,只在今朝！",
}

songwei:addEffect(fk.CardUseFinished, {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(songwei.name) and target ~= player and target.kingdom == "wei" and player:getMark("@ls__dengji") ~= 0
    and data.card.trueName == player:getMark("@ls__dengji")
    and (player:usedSkillTimes("ls__dengji", Player.HistoryGame) > 0 or #player:getTableMark("ls__weishe-round") > 0)
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(target, { skill_name = songwei.name, prompt = "#ls__songwei-reset:".. player.id })
  end,
  on_use = function(self, event, target, player, data)
    local choices = {}
    if player:usedSkillTimes("ls__dengji", Player.HistoryGame) > 0 then
      table.insertIfNeed(choices, "ls__dengji")
    end
    if #player:getTableMark("ls__weishe-round") > 0 then
      table.insertIfNeed(choices, "ls__weishe")
    end
    if #choices > 0 then
      local choice = player.room:askToChoice(target, {choices = choices, skill_name = songwei.name})
      if choice == "ls__dengji" then
        player.room:setPlayerMark(player, "@ls__dengji", 0)
        player:setSkillUseHistory("ls__dengji", 0, Player.HistoryGame)
      elseif choice == "ls__weishe" then
        player.room:setPlayerMark(player, "ls__weishe-round", 0)
      end
    end
  end,
})

return songwei
